#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int longestSubarray(vector<int>& nums) {
        int mmax = 0, res = 0, count = 0;
        for (auto& e : nums)
        {
            if (e > mmax)
                mmax = e;
        }
        for (auto& e : nums)
        {
            if (e == mmax)
                ++count;
            else
            {
                res = max(res, count);
                count = 0;
            }
        }
        res = max(res, count);
        return res;
    }
};